package com.example.demo.entity;

import java.io.Serializable;
import java.util.Objects;

/**
 * 对应数据库的用户表
 */
public class User  implements Serializable {

    private static  final long serialVersionUID = 1L;

    private int uid;
    private String username;  //对应的是数据库的uname字段
    private String upassword; //密码
    private String img;//图片
    private String usex; //性别
    private Integer uage;
    private int urole; //用户 0 管理员 1


    public Integer getUage() {
        return uage;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return uid == user.uid && urole == user.urole && Objects.equals(username, user.username) && Objects.equals(upassword, user.upassword) && Objects.equals(img, user.img) && Objects.equals(usex, user.usex) && Objects.equals(uage, user.uage);
    }

    public User(int uid, String username, String upassword, String usex, Integer uage, int urole) {
        this.uid = uid;
        this.username = username;
        this.upassword = upassword;
        this.usex = usex;
        this.uage = uage;
        this.urole = urole;
    }

    public User(String username, String upassword) {
        this.username = username;
        this.upassword = upassword;
    }

    @Override
    public int hashCode() {
        return Objects.hash(uid, username, upassword, img, usex, uage, urole);
    }

    @Override
    public String toString() {
        return "User{" +
                "uid=" + uid +
                ", username='" + username + '\'' +
                ", upassword='" + upassword + '\'' +
                ", img='" + img + '\'' +
                ", usex='" + usex + '\'' +
                ", uage=" + uage +
                ", urole=" + urole +
                '}';
    }

    public void setUage(Integer uage) {
        this.uage = uage;
    }

    public User(int uid, String username, String upassword, String img, String usex, Integer uage, int urole) {
        this.uid = uid;
        this.username = username;
        this.upassword = upassword;
        this.img = img;
        this.usex = usex;
        this.uage = uage;
        this.urole = urole;
    }




    public User() {
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public int getUid() {
        return uid;
    }

    public void setUid(int uid) {
        this.uid = uid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getUpassword() {
        return upassword;
    }

    public void setUpassword(String upassword) {
        this.upassword = upassword;
    }

    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public String getUsex() {
        return usex;
    }

    public void setUsex(String usex) {
        this.usex = usex;
    }

    public int getUrole() {
        return urole;
    }

    public void setUrole(int urole) {
        this.urole = urole;
    }

}
